local zhenglun = fk.CreateSkill{
  name = "doublez__zhenglun"
}

Fk:loadTranslationTable{
  ["doublez__zhenglun"] = "整论",
  [":doublez__zhenglun"] = "出牌阶段限一次，你可以摸两张牌并弃置至少两张牌，然后展示所有手牌，"
    .."若其中包含花色数为2或4，你视为使用牌名字数为此值的一张普通锦囊牌。",
  
  ["#doublez__zhenglun"] = "你可以发动“整论”",
  ["#doublez__zhenglun_discard"] = "整论：弃置至少两张牌",
  ["#doublez__zhenglun_use"] = "整论：使用一张锦囊牌",

  ["$doublez__zhenglun1"] = "整论四海未泰，修文德以平。",
  ["$doublez__zhenglun2"] = "今论者不务道德怀取之术，而惟尚武，窃所未安。",
}

zhenglun:addEffect("active",{
  can_use = function (self, player)
    return player:usedSkillTimes(zhenglun.name) < 1
  end,
  card_filter = Util.FalseFunc,
  target_filter = Util.FalseFunc,
  prompt = "#doublez__zhenglun",
  on_use = function (self, room, effect)
    local player = effect.from
    player:drawCards(2, zhenglun.name)
    if player.dead or player:getHandcardNum() < 2 then return end

    room:askToDiscard(player,{
      min_num = 2,
      max_num = 999,
      skill_name = zhenglun.name,
      cancelable = false,
      include_equip = true,
      prompt = "#doublez__zhenglun_discard"
    })
    if player.dead then return end

    player:showCards(player:getCardIds(Player.Hand))
    room:delay(800)
    local suits = {}

    table.forEach(player:getCardIds(Player.Hand), function (cid)
      table.insertIfNeed(suits, Fk:getCardById(cid).suit)
    end)

    table.removeOne(suits, Card.NoSuit)
    if #suits ~= 2 and #suits ~= 4 then return end

    local card_names = table.filter(Fk:getAllCardNames("t"), function(card_name)
      return #suits == Fk:translate(card_name, "zh_CN"):len()
    end)

    card_names = player:getViewAsCardNames(zhenglun.name, card_names)
    if #card_names == 0 then return end
    room:askToUseVirtualCard(player, {
      name = card_names,
      skill_name = zhenglun.name,
      cancelable = false,
      prompt = "#doublez__zhenglun_use"
    })
  end
})

return zhenglun